<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<link rel="stylesheet"
	href="http://static.runoob.com/assets/js/jquery-treeview/jquery.treeview.css" />

<script src="https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
<script
	src="http://static.runoob.com/assets/js/jquery-treeview/jquery.treeview.js"
	type="text/javascript"></script>
<meta hzttp-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>ZZTY</title>
</head>
<style>
textarea {
	width: 99%;
	height: 100%;
}
</style>
<script
	src="http://cdn.static.runoob.com/libs/jquery/2.1.1/jquery.min.js"></script>
<script type="text/javascript">
	
	$(document).ready(function() {

				var jsonObj;
				var userId = getUrlParam('id');
				var examdate = getUrlParam('date');
				var operations = getUrlParam('operation');
				$.ajax({
					type : "GET",
					url : "Answer/search/" + userId + "/" + examdate + "/" + operations,
// 					dataType : "json",
					contentType : "application/json",
					success : function(data) {
						if(data.length == 2){
							alert("答案不存在");
							window.close();
						}
						jsonObj = JSON.parse(data);
						var branches;
						$.each(jsonObj, function(key, value) {
							branches = "<li><span class='file'>" + key
									+ "</span></li>";
							$("#browser").append(branches);
						})
					},
					error : function(data) {
						alert("答案不存在");
						window.close();
					}
				});

				$.get("History/getComment/"+userId + "/" + examdate + "/" + operations,function(data){
					$("#comment").text(data);
				})
				
				$("#browser").on('click', '.file', function() {
					var tmp = $(this).text();
					$.each(jsonObj, function(key, value) {
						if (tmp == key) {
							$("#div1").empty();
							$("#div1").append(value);
						}
					});

				});

				function getUrlParam(name) {
					var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
					var r = window.location.search.substr(1).match(reg); //匹配目标参数
					if (r != null)
						return unescape(r[2]);
					return null; //返回参数值
				}
				
			});
</script>

<body>

	<h3 id="banner">历史作业查看</h3>
	<hr>
	<div id="main" style="width: 100%">
		<div style="width: 15%; float: left;">
			<ul id="browser" class="filetree treeview-famfamfam">
			</ul>
		</div>
		<div id="div1"
			style="width: 84%; height: 600px; float: left; overflow-y: scroll"></div>
		<div style="clear: both;"></div>
	</div>
	<div style="width: 33%; float: left">
		评语
		<textarea id="comment" id="tarea3" rows="10" cols="35" readonly="readonly"
			style="background: transparent"></textarea>

	</div>
</body>
</html>